package game;

import java.io.BufferedWriter;
import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

import player.Player;

// super class
public class SuperGame {

	// list containing players participating to one game
	List<Player> playerList = new ArrayList<Player>();


	// the game is over if the value equals true
	private boolean gameOver = false;

	// the game has been started if the value equals true
	// and no more player will be accepted
	private boolean isStarted = false;

	// number of players required for a game to start
	private int nbPlayer = 0;

	// game's name
	private String kindOfGame = "";
	// if the game is a turn based strategy
	private boolean isTpt = false;

	// class' constructor : set kind of selected game & add new player to the game
	public SuperGame(String tmpGame, Player player) {
		setKindOfGame(tmpGame);
		addNewPlayer(player);
	}

	// getters and setters
	public boolean isGameOver() {
		return gameOver;
	}

	public void setGameOver(boolean gameOver) {
		this.gameOver = gameOver;
	}

	public boolean isStarted() {
		return isStarted;
	}

	public void setStarted(boolean isStarted) {
		this.isStarted = isStarted;
	}

	public List<Player> getListPlayer() {
		return this.playerList;
	}

	public void setListPlayer(List<Player> listPlayer) {
		this.playerList = listPlayer;
	}

	public String getKindOfGame() {
		return kindOfGame;
	}

	public void setKindOfGame(String kindOfGame) {
		this.kindOfGame = kindOfGame;
	}

	public int getNbJoueur() {
		return nbPlayer;
	}

	public void setNbJoueur(int nbJoueur) {
		this.nbPlayer = nbJoueur;
	}

	public void addNewPlayer(Player p) {

		this.playerList.add(p);

	}

	public boolean isTpt() {
		return isTpt;
	}

	public void setTpt(boolean isTpt) {
		this.isTpt = isTpt;
	}

	public void play() {

	}

	public void getAction(String action) {

	}

	public void sendMsg(String msg, BufferedWriter bufOut) {
		try {
			bufOut.write(msg);
			bufOut.newLine();
			bufOut.flush();
		} catch (IOException e) {
			System.out
					.println("An error has been occured while sending the message to the player");
			e.printStackTrace();
		}
	}

	public void refreshBoard(String msg) {

	}

	public void displayBoard(Socket socket) throws IOException {

	}
}
